Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gamepad support #111

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nanoflite
Copy link

@nanoflite nanoflite commented Aug 15, 2018

A working gamepad implementation for pgzero.

Only 2 gamepads are supported and there's keyboard support as well.

Gamepad 1 is mapped to the buttons of the first connected gamepad and the keys 'WASD'+space.
Gamepad 2 is mapped to the buttons of the second connected gamepad and the keys 'IJKL'+m

Some gamepads use different axis then 0 and 1 for the default X and Y directions, to accommodate that there's a global define possible, just like HEIGHT for example. This global define is:
GAMEPAD_1_X_AXIS, GAMEPAD_1_Y_AXIS, GAMEPAD_2_X_AXIS, GAMEPAD_2_Y_AXIS.

There's the following event handlers:
on_gamepad_1_pressed, on_gamepad_1_released, on_gamepad_2_pressed, on_gamepad_2_released

In the update function you can check the gamepads as well:

    if gamepad_1[gamepad.UP]:
        print('UP ON ONE')

or

    if gamepad_1.down:
        print('DOWN ON ONE')

Cheers,
Johan

@lordmauve
Copy link
Owner

(I haven't had time to look at this yet, am getting married next week. Will look soon!)

@nanoflite
Copy link
Author

nanoflite commented Aug 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants